/**
 * 包含reducer函数：根据老的state和指定的action返回一个新的state
 */
import { combineReducers } from 'redux'
import { AUTH_FAILED, AUTH_SUCCESS } from './action-types';

const initUser={
    name:"guest"
}

function user (state=initUser,action){
    switch (action.type) {
    case AUTH_SUCCESS:
      return action.data
    case AUTH_FAILED:
        return {...state,errorMessage:action.data}
    default:
      return state
    }
}

function plans (state=0,action){
    return state;
}

export default combineReducers({
    user,
    plans
})